﻿using Common.Communal;
using ERP.Domain.Products;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Product.API.Read.Applications.Commands.ProductProcess;
using Product.API.Read.DTOS;
using Repository.communal;

namespace Product.API.Read.Controllers
{
    /// <summary>
    /// 产品工艺API-读
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ProductProcessController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        private readonly IBaseRepository<ProductProcess> productProcessRepository;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ProductProcessController(IMediator mediator,IBaseRepository<ProductProcess> productProcessRepository)
        {
            this.mediator = mediator;
            this.productProcessRepository = productProcessRepository;
        }

        /// <summary>
        /// 产品显示
        /// </summary>
        /// <returns></returns>
        [HttpGet("ProductProcess")]
        public Task<ApiResult<ApiPaging<ERP.Domain.Products.Product>>> ProductProcess([FromQuery] ProductCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 关联产品显示
        /// </summary>
        /// <returns>返回任务</returns>
        [HttpGet("ProductProcessShow")]
        public Task<ApiResult<List<ProductProcessShowDTO>>> ProductProcessShow(Guid processRouteNumber)
        {
            ProductProcessShowCommand command = new ProductProcessShowCommand();
            command.processRouteNumber = processRouteNumber;
            return mediator.Send(command);
        }

    }
}
